||(OR) Operator
The OR operator is somewhat opposite of the ‘AND’ operator. It also evaluates the operator from left to right and returns true even if one operand is evaluated as true
Example: In this example, we will perform OR operation on different data types and check their boolean output.
// ||(OR) Operator
let i = 1;
let j = null;
let k = undefined;
let l = 0;
console.log(Boolean(j||k));
console.log(Boolean(i||l));
Output:
false
true
Explanation: null, undefined, and 0 are recognized as falsy values. So OR operation on null and undefined will give false whereas numbers except 0 are treated as true.
Supported Browsers: The browsers supported by all JavaScript Logical operators are listed below:
- Google Chrome
- Firefox
- Opera
- Safari
- Microsoft Edge
- Internet Explorer
We have a complete list of Javascript Operators, to check those please go through this Javascript Operators Complete reference article.
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
Contact Us